/// 资讯文章模型
class Article {
  final int articleId;
  final String title;
  final String? content;
  final String? source;
  final String? url;
  final String? articleType;
  final int? companyId;
  final String? companyCode;
  final String? companyName;
  final String? companyNameCn;
  final String? companyLogo;
  final String? publishTime;
  final String? audioDuration;
  final String? status;
  final String? createTime;
  final String? updateTime;
  bool? isFavorite;

  Article({
    required this.articleId,
    required this.title,
    this.content,
    this.source,
    this.url,
    this.articleType,
    this.companyId,
    this.companyCode,
    this.companyName,
    this.companyNameCn,
    this.companyLogo,
    this.publishTime,
    this.audioDuration,
    this.status,
    this.createTime,
    this.updateTime,
    this.isFavorite,
  });

  factory Article.fromJson(Map<String, dynamic> json) {
    return Article(
      articleId: json['articleId'],
      title: json['title'] ?? '',
      content: json['content'],
      source: json['source'],
      url: json['url'],
      articleType: json['articleType'],
      companyId: json['companyId'],
      companyCode: json['companyCode'],
      companyName: json['companyName'],
      companyNameCn: json['companyNameCn'],
      companyLogo: json['companyLogo'],
      publishTime: json['publishTime'],
      audioDuration: json['audioDuration']?.toString(),
      status: json['status'],
      createTime: json['createTime'],
      updateTime: json['updateTime'],
      isFavorite: json['isFavorite'] ?? false,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'articleId': articleId,
      'title': title,
      'content': content,
      'source': source,
      'url': url,
      'articleType': articleType,
      'companyId': companyId,
      'companyCode': companyCode,
      'companyName': companyName,
      'companyNameCn': companyNameCn,
      'companyLogo': companyLogo,
      'publishTime': publishTime,
      'audioDuration': audioDuration,
      'status': status,
      'createTime': createTime,
      'updateTime': updateTime,
      'isFavorite': isFavorite,
    };
  }
}

